package Class020;

import Utils.ArrayUtils;

import java.util.Arrays;

public class Recursion {
    public static void main(String[] args) {
        int[] arr = ArrayUtils.generateArray(10, 20);
        System.out.println(Arrays.toString(arr));
        System.out.println("最大值:" + findMax(arr, 0, arr.length - 1));
    }

    public static int findMax(int[] arr, int l, int r) {
        if(l == r) return arr[l];
        int mid = l + ((r - l) >> 1);
        int left = findMax(arr, l, mid);
        int right = findMax(arr, mid + 1, r);
        return Math.max(left, right);
    }
}
